﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Site.master" AutoEventWireup="true" 
    CodeFile="WIN02_4A.aspx.cs" Inherits="IFRS_WIN02_4A" %>

<%@ Register Assembly="vsm.WebControls" Namespace="vsm.WebControls" TagPrefix="vsm" %>
<%@ Register Assembly="vsm.CustomControl" Namespace="vsm.CustomControl" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link href="../Content/plugins/jquery-ui/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

        window.SetValueCurrency = function (Value1, Value2) {
             document.getElementById("<%= hidCurrencyCode.ClientID %>").value = Value1;
             document.getElementById("<%= txtCurrencyCode.ClientID %>").value = Value1;
         }

         window.SetValueGLAccount = function (Value1, Value2) {
             document.getElementById("<%= hidGLAccountCode.ClientID %>").value = Value1;
             document.getElementById("<%= txtGLAccountCode.ClientID %>").value = Value1;
         }

         window.SetValueCostCenter = function (Value1, Value2) {
             document.getElementById("<%= hidCostCenter.ClientID %>").value = Value1;
             document.getElementById("<%= txtCostCenter.ClientID %>").value = Value2;
         }

         window.SetValueRefInterest = function (Value1, Value2) {
            document.getElementById("<%= hidReferenceInterestCD.ClientID %>").value = Value1;
            document.getElementById("<%= txtReferenceInterestCD.ClientID %>").value = Value2;
         }

         window.SetValueCustomer = function (Value1, Value2) {
             document.getElementById("<%= hidCustomer.ClientID %>").value = Value1;
             document.getElementById("<%= txtCustomer.ClientID %>").value = Value2;
         }

         window.SetValueVmLoadObjective = function (Value1, Value2) {
             document.getElementById("<%= hidLoanObjective.ClientID %>").value = Value1;
             document.getElementById("<%= txtLoanObjective.ClientID %>").value = Value2;
         }

    </script>
    <script type="text/javascript">
        function OnSelectedIndexChange() {            
            if (document.getElementById('<%= ddlInterestType.ClientID %>').value = 1) {

                document.getElementById('<%= txtInterestRate.ClientID %>').textContent = '';
                document.getElementById('<%= txtInterestRate.ClientID %>').style.backgroundColor = "#ffffff"; // สีขาว
                document.getElementById('<%= txtInterestRate.ClientID %>').disabled = true;      
                
                document.getElementById('<%= txtReferenceInterestCD.ClientID %>').textContent = '';
                document.getElementById('<%= txtReferenceInterestCD.ClientID %>').style.backgroundColor = "#f0f0f0"; // สีเทา
                document.getElementById('<%= txtReferenceInterestCD.ClientID %>').disabled = false;
                document.getElementById('<%= btnReferenceInterestCD.ClientID %>').disabled = false;
            }            
        }
    </script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {

            var interestType = $('#<%=ddlInterestType.ClientID%>');
            var txtIntRate = $('#<%=txtInterestRate.ClientID%>');
            var txtRefIntCD = $('#<%=txtReferenceInterestCD.ClientID%>');
            var btnRefIntCD = $('#<%=btnReferenceInterestCD.ClientID%>');
            var hidRefIntCD = $('#<%=hidReferenceInterestCD.ClientID%>');
                                
            interestType.change(function (e) {

                if (interestType.val() == '1') { // อัตราคงที่
                    
                    txtIntRate.val('0.000000');
                    txtIntRate.css('background-color', '#ffffff');
                    txtIntRate.removeAttr("disabled");

                    txtRefIntCD.val('');                    
                    txtRefIntCD.css('background-color', '#f0f0f0');
                    txtRefIntCD.attr("disabled", "disabled");
                    btnRefIntCD.attr("disabled", "disabled");
                    hidRefIntCD.val('');

                }
                else if (interestType.val() == '2') { // อัตราลอยตัว

                    txtIntRate.val('');                    
                    txtIntRate.css('background-color', '#f0f0f0');
                    txtIntRate.attr("disabled", "disabled");
                    
                    txtRefIntCD.css('background-color', '#ffffff');
                    txtRefIntCD.removeAttr("disabled");
                    btnRefIntCD.removeAttr("disabled");
                }

            });

        });           
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="container-custom">
        <div class="table_master">
            <div class="table_detail">
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblTransactionDate" runat="server" Text="<%$Resources:ifrsField,DATE_TRANSACTION%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:TextBox ID="txtTransactionDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqTransactionDate" runat="server" ErrorMessage=""
                            ControlToValidate="txtTransactionDate" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblAccountNo" runat="server" Text="<%$Resources:ifrsField,ACCOUNTNO_CREDIT%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:TextBox ID="txtAccountNo" runat="server" SkinID="TextBoxWithNoColor"></asp:TextBox>
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqAccountNo" runat="server" ErrorMessage=""
                            ControlToValidate="txtAccountNo" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblGLAccountCode" runat="server" Text="<%$Resources:ifrsField,GL_ACCOUNT%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <cc1:TextboxAutoComplete ID="txtGLAccountCode" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnGLAccountCode" runat="server" Text="..." />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqGLAccountCode" runat="server" ErrorMessage=""
                            ControlToValidate="txtGLAccountCode" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblCostCenter" runat="server" Text="<%$Resources:ifrsField,COST_CENTER%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <cc1:TextboxAutoComplete ID="txtCostCenter" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnCostCenter" runat="server" Text="..." />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqCostCenter" runat="server" ErrorMessage=""
                            ControlToValidate="txtCostCenter" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblStartDate" runat="server" Text="<%$Resources:ifrsField,STARTDATE_CONTRACT_LOAN%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                       
                        <asp:TextBox ID="txtStartDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblEndDate" runat="server" Text="<%$Resources:ifrsField,ENDDATE_CONTRACT_LOAN%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <asp:TextBox ID="txtEndDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblLastPayDate" runat="server" Text="<%$Resources:ifrsField,LAST_PAYMENT_DATE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <asp:TextBox ID="txtLastPayDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqLastPayDate" runat="server" ErrorMessage=""
                            ControlToValidate="txtLastPayDate" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblNextPayDate" runat="server" Text="<%$Resources:ifrsField,NEXT_PAYMENT_DATE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <asp:TextBox ID="txtNextPayDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqNextPayDate" runat="server" ErrorMessage=""
                            ControlToValidate="txtNextPayDate" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>                
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblPaymentFreq" runat="server" Text="<%$Resources:ifrsField,PAYMENT_FREQUENCY%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                                               
                        <cc1:TextboxNumber ID="txtPaymentFreq" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="0" TypeTextbox="Currency" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblPaymentFreqTimeBase" runat="server" Text="<%$Resources:ifrsField,PAYMENT_FREQUENCY_TIME_BASE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlPaymentFreqTimeBase" runat="server" SkinID="DropDownListWithNoColor" />
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblPaymentCondition" runat="server" Text="<%$Resources:ifrsField,PAYMENT_CONDITION%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlPaymentCondition" runat="server" SkinID="DropDownListWithNoColor" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblCalInterestCond" runat="server" Text="<%$Resources:ifrsField,CALCULATING_INTEREST_CONDITION%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlCalInterestCond" runat="server" SkinID="DropDownListWithNoColor" />
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblInterestType" runat="server" Text="<%$Resources:ifrsField,INTEREST_RATE_TYPE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlInterestType" runat="server" SkinID="DropDownListWithNoColor" />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqInterestType" runat="server" ErrorMessage=""
                            ControlToValidate="ddlInterestType" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>

                    <div class="collabel">
                        <asp:Label ID="lblInterestRate" runat="server" Text="<%$Resources:ifrsField,INTEREST_RATE_PER_YEAR%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <cc1:TextboxNumber ID="txtInterestRate" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="6" TypeTextbox="Currency" />&nbsp;
                        <asp:Label ID="lblPERCENT" runat="server" Text="<%$Resources:ifrsField,PERCENT%>" />
                    </div>
                </div>
                <div class="rowinfo">                   
                    <div class="collabel">
                        <asp:Label ID="lblReferenceInterestCD" runat="server" Text="<%$Resources:ifrsField,REFERENCEINTERESTCD%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <cc1:TextboxAutoComplete ID="txtReferenceInterestCD" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnReferenceInterestCD" runat="server" Text="..." CausesValidation="False" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblAdditionalInterest" runat="server" Text="<%$Resources:ifrsField,ADDITION_OF_REFERENCE_INTEREST_RATE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <cc1:TextboxNumber ID="txtAdditionalInterest" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="6" TypeTextbox="Currency" />&nbsp;
                        <asp:Label ID="lblPERCENT2" runat="server" Text="<%$Resources:ifrsField,PERCENT%>" />
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblDayCountMethod" runat="server" Text="<%$Resources:ifrsField,DAY_COUNT_METHOD%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlDayCountMethod" runat="server" SkinID="DropDownListWithNoColor" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblCurrencyCode" runat="server" Text="<%$Resources:ifrsField,CURRENCYCODE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <cc1:TextboxAutoComplete ID="txtCurrencyCode" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnCurrencyCode" runat="server" Text="..." />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqCurrencyCode" runat="server" ErrorMessage=""
                            ControlToValidate="txtCurrencyCode" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblUnpaidInterest" runat="server" Text="<%$Resources:ifrsField,UPPAID_INTEREST%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <cc1:TextboxNumber ID="txtUnpaidInterest" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="2" TypeTextbox="Currency" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblDept" runat="server" Text="<%$Resources:ifrsField,TOTAL_DEBT_OUTSTANDING%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <cc1:TextboxNumber ID="txtDept" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="2" TypeTextbox="Currency" />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqDept" runat="server" ErrorMessage=""
                            ControlToValidate="txtDept" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblCreditLevel" runat="server" Text="<%$Resources:ifrsField,CREDIT_LEVEL%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlCreditLevel" runat="server" SkinID="DropDownListWithNoColor" />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqCreditLevel" runat="server" ErrorMessage=""
                            ControlToValidate="ddlCreditLevel" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblCustomer" runat="server" Text="<%$Resources:ifrsField,CUSTOMER_NO_CIF%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                                                                            
                        <cc1:TextboxAutoComplete ID="txtCustomer" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnCustomer" runat="server" Text="..." />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqCustomer" runat="server" ErrorMessage=""
                            ControlToValidate="txtCustomer" Display="Dynamic"></asp:RequiredFieldValidator>                                 
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblContractLoanType" runat="server" Text="<%$Resources:ifrsField,CONTRACT_LOAN_TYPE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:DropDownList ID="ddlContractLoanType" runat="server" SkinID="DropDownListWithNoColor" />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqContractLoanType" runat="server" ErrorMessage=""
                            ControlToValidate="ddlContractLoanType" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblLoanObjective" runat="server" Text="<%$Resources:ifrsField,LOAN_OBJECTIVE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                                                
                        <cc1:TextboxAutoComplete ID="txtLoanObjective" runat="server" SkinID="TextBoxWithNoColor"></cc1:TextboxAutoComplete>
                        <asp:Button ID="btnLoanObjective" runat="server" Text="..." />
                        <span class="red">*</span>
                        <asp:RequiredFieldValidator ID="reqLoanObjective" runat="server" ErrorMessage=""
                            ControlToValidate="txtLoanObjective" Display="Dynamic"></asp:RequiredFieldValidator>   
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblFirstMisDate" runat="server" Text="<%$Resources:ifrsField,FIRST_MISTAKE_DATE%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <asp:TextBox ID="txtFirstMisDate" CssClass="datepicker" SkinID="dateText" 
                                runat="server" onblur="datebox_onblur( this, event );" ></asp:TextBox>
                    </div>

                    <div class="collabel">
                        <asp:Label ID="lblAdjustFlag" runat="server" Text="<%$Resources:ifrsField,LIST_OF_RESTRUCTURING%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <asp:CheckBox ID="chkAdjustFlag" runat="server"></asp:CheckBox>
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                        <asp:Label ID="lblReservedAmount" runat="server" Text="<%$Resources:ifrsField,RESERVE_AMOUNT%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">                        
                        <cc1:TextboxNumber ID="txtReservedAmount" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="2" TypeTextbox="Currency" />
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblApprovedAmount" runat="server" Text="<%$Resources:ifrsField,APPROVE_AMOUNT%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <cc1:TextboxNumber ID="txtApprovedAmount" runat="server" SkinID="TextBoxWithNoColor" 
                            MaxLength="10" DigitDecimal="2" TypeTextbox="Currency" />                       
                    </div>
                </div>
                <div class="rowinfo">
                    <div class="collabel">
                    </div>
                    <div class="colinfo">
                    </div>
                    <div class="collabel">
                        <asp:Label ID="lblStatus" runat="server" Text="<%$Resources:ifrsField,LIST_STATUS%>" />&nbsp;:&nbsp;
                    </div>
                    <div class="colinfo">
                        <asp:TextBox ID="txtStatus" runat="server" SkinID="ReadOnlyBox"></asp:TextBox>                        
                    </div>
                </div>
            </div>
            <div class="colbtn">
                <asp:Button ID="btnSAVE_NEW" SkinID="NormalButton" runat="server" Text="<%$Resources:ifrsButton,SAVE_NEW%>" onclick="btnSAVE_NEW_Click" />&nbsp;
                <asp:Button ID="btnSAVE" SkinID="NormalButton" runat="server" Text="<%$Resources:ifrsButton,SAVE%>" onclick="btnSAVE_Click" />&nbsp;
                <asp:Button ID="btnCLEAR" SkinID="NormalButton" runat="server" Text="<%$Resources:ifrsButton,CLEAR%>" OnClick="btnCLEAR_Click" />&nbsp;
                <asp:Button ID="btnCANCEL" SkinID="NormalButton" runat="server" Text="<%$Resources:ifrsButton,CANCEL%>" onclick="btnCANCEL_Click" />
            </div>
        </div>
    </div>    
    <asp:HiddenField ID="hidManualLoanID" runat="server" />
    <asp:HiddenField ID="hidUpdateDate" runat="server" />

    <asp:HiddenField ID="hidGLAccountCode" runat="server" />
    <asp:HiddenField ID="hidCostCenter" runat="server" />
    <asp:HiddenField ID="hidReferenceInterestCD" runat="server" />
    <asp:HiddenField ID="hidCurrencyCode" runat="server" />
    <asp:HiddenField ID="hidCustomer" runat="server" />    
    <asp:HiddenField ID="hidLoanObjective" runat="server" />    

    <script src="../Content/js/Currency.js" type="text/javascript"></script>
    <script src="../Content/plugins/jquery-ui/ui/jquery.ui.core.js" type="text/javascript"></script>
    <script src="../Content/plugins/jquery-ui/ui/jquery.ui.widget.js" type="text/javascript"></script>
    <script src="../Content/plugins/jquery-ui/ui/jquery.ui.datepicker.js" type="text/javascript"></script>
    <script src="../Content/plugins/custom.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $(".datepicker").initDatepicker();
        });
    </script>
</asp:Content>

